package Gather.MapExercise.TreeMap;

import java.util.TreeMap;

/**
 * ClassName:TreeMap003
 * Package:Gather.MapExercise.TreeMap
 * Description:
 *
 * @Author:ZhangXin
 * @Create2023/2/20-21:29
 * @Version:v1.0
 */
public class TreeMap003 {
    /*需求
    * 1.键:学生对象
    * 2.值:籍贯
    * 要求:按照学生年龄的升序排序,年龄一样按照姓名的字母排序,同姓名年龄视为同一个人*/
    public static void main(String[] args) {
        //创建集合
        TreeMap<Student,String> treeMap = new TreeMap<>();
        //创建学生对象
        Student s1 = new Student("zhangsan",23);
        Student s2 = new Student("lisi",24);
        Student s3 = new Student("wangwu",25);
        Student s4 = new Student("zhaoliu",26);
        //添加元素
        treeMap.put(s1,"山西");
        treeMap.put(s2,"北京");
        treeMap.put(s3,"山东");
        treeMap.put(s4,"江苏");

        System.out.println(treeMap);
    }
}
